Mega Code Archive
Date Timezone
1) Add 12 minutes to 24th March 1964
2) Adding to a Date Using the Addition Operator
3) Combine DateADD and DateDIFF to get the last date of a month
4) Combine the CONVERT()and the DATEADD() functions to format a return date value nine months before September 8, 1989
5) CONVERT date to varchar
6) CONVERT(VarChar(50), GETDATE(), 100)
7) CONVERT(VarChar(50), GETDATE(), 101)
8) CONVERT(VarChar(50), GETDATE(), 102)
9) CONVERT(VarChar(50), GETDATE(), 103)
10) CONVERT(VarChar(50), GETDATE(), 104)
11) CONVERT(varchar, getdate(), 1(2,3,4,5,6))
12) CONVERT(varchar,GETDATE(),108) hh
13) CONVERT(varchar,GETDATE(),113) dd Mmm yyyy hh
14) CONVERT(varchar,GETDATE(),114) hh
15) Converted to a datetime
16) DATEADD
17) DATEADD(Day, 90, 4-29-1988)
18) DATEADD(mi, -9000000, 4-29-1988 10
19) DATEADD(second, 9000, 4-29-1988 10
20) DATEADD(year, 18, 4-29-1988 10
21) DATEADD(yy, -18, 4-29-1988 10
22) DATEDIFF
23) DATEDIFF(d, @thisdate, @nextmonth) Days between
24) DATEDIFF(day, 9-8-1989, 10-17-1991)
25) DATEDIFF(m, 24 March 2001,24 March 1964)
26) DATEDIFF(mi, 24 March 2001,24 March 1964)
27) DATEDIFF(month, 9-8-1989, 10-17-1991)
28) DATEDIFF(ss, @MyBirthDate, GETDATE())
29) DATEDIFF(wk, 24 March 2001,24 March 1964)
30) DATEDIFF(yyyy, 24 March 2001,24 March 1964)
31) DATENAME
32) DATENAME returns the part of the date in a literal form
33) DATENAME(month, 4-29-1988) returns a string containing the descriptive name
34) DATEPART
35) DATEPART(dw,GETDATE())
36) DATEPART(m,GETDATE())
37) DATEPART(mi,GETDATE())
38) DATEPART(month, 4-29-1988)
39) DATEPART(n,GETDATE())
40) DATEPART(wk,GETDATE())
41) DATEPART(yy,GETDATE())
42) Dateparts and Abbreviations
43) DATETIME column
44) DAY
45) Day(Date) function
46) Declare an int variable and use it in select statement
47) Difference between the current time and UTC
48) Difference in weeks between 7-2-1996 and 8-4-1997
49) Evaluating Whether An Expression Is a Date or Is Numeric
50) Find out the month name in two months time
51) Find the number of days between 24th March 2001 and 24th March 1964
52) Format date
53) Get current date in procedure
54) Get Day only from a datetime variable
55) GETDATE
56) GETDATE()
57) GETUTCDATE
58) GETUTCDATE()
59) MONTH
60) Month(Date) function
61) Passing a column name to the DATEDIFF() value argument
62) Reference Date data type as string (char)
63) Returning the Current Date and Time by using CURRENT_TIMESTAMP
64) SELECT DATEADD(dayofyear, 18, 4-29-1988 10
65) SELECT DATEADD(hh,12,24 March 1964)
66) SELECT DATEADD(m,12,24 March 1964)
67) SELECT DATEADD(mi, -30, 2005-09-01 23
68) Select DATEADD(month, -1, 2002-09-30 11
69) SELECT DATEADD(quarter, 18, 4-29-1988 10
70) SELECT DATEADD(wk,12,24 March 1964)
71) SELECT DATEADD(yy,12,24 March 1964)
72) Select DATEDIFF(hour, 06
73) Select DATEDIFF(minute, 06
74) Select DATEDIFF(quarter, 2001-12-01, 2002-09-30)
75) Select DATEDIFF(second, 06
76) Select DATENAME(day, 2002-09-30 11
77) Select DATENAME(dayofyear, 2002-09-30 11
78) Select DATENAME(hour, 2002-09-30 11
79) Select DATENAME(minute, 2002-09-30 11
80) Select DATENAME(quarter, 2002-09-30 11
81) Select DATENAME(second, 2002-09-30 11
82) Select DATENAME(week, 2002-09-30 11
83) Select DATENAME(weekday, 2002-09-30 11
84) Select DATENAME(year, 2002-09-30 11
85) Select DATEPART(dayofyear, 2002-09-30 11
86) Select DATEPART(quarter, 2002-09-30 11
87) Select DATEPART(week, 2002-09-30 11
88) Select DATEPART(weekday, 2002-09-30 11
89) Select DAY(2002-09-30)
90) SELECT ISDATE(112000)
91) Select ISDATE(2002-09-30)
92) Select ISDATE(2002-09-31)
93) Select ISDATE(23
94) Select MONTH(2002-09-30)
95) Select YEAR(2002-09-30)
96) The DAY(), MONTH(), and YEAR() Functions
97) Update the record with the current data and time using the GETDATE() function
98) Using Functions in Queries
99) Using the DATENAME() Function
100) YEAR